<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>list</title>
[#include "/admin/include/head.htm"]
</head>
<body>
<script type="text/javascript">
	//设置为自动刷新
	setInterval("refresh_grid()", 3000); 
    var grid;
		
    $(function () {
        grid = $("#maingrid").ligerGrid({
            columns: [
			{display: 'ID', name: 'id', width:50, align: 'left', isAllowHide: false},
			{display: '标题', name: 'title', align: 'left', minWidth: 500 },
			{display: '作者', name: 'author', align: 'left', width: 100, align: 'center' },
            {display: '分类', name: 'category.name', align: 'left', width: 150, align: 'center' },
			{display: '是否发布', name: 'isPublication', align: 'center',dict:'common.is', width: 80 },
			{display: '是否推荐', name: 'isRecommend', align: 'center',dict:'common.is', width: 80 },
			{display: '创建时间', name: 'createDate', align: 'center', width: 150 ,type: 'Date'},
			{display: '发布时间', name: 'releaseDate', align: 'center', width: 150 ,type: 'Date'}
			],  pageSize:20, 
			url: '${base}/admin/system/article/queryData.jhtml?id=' + getQueryStringByName("id"),
			toolbar: {}, width: '100%', height:'100%', enabledSort: true,
			groupColumnName:'category.name',groupColumnDisplay:'<span style="color:red;">类型</span>'
        });
        
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
    });
    
    function add(){
    	top.f_addTab(null, '新增文章', '${base}/admin/system/article/add.jhtml?parentMenuNo=${(parentMenuNo)!""}&catId=' + getQueryStringByName("id"));
    }
    
    function edit(){
    	var selecteds = grid.getSelecteds();
    	if (selecteds.length != 1) { 
    		LG.tip('请选择一行记录!'); 
    		return; 
    	}
		var id = selecteds[0].id;
		if(top.f_isTabItemExist("article" + id)){
			top.f_switchTab("article" + id);
		}else{
			top.f_addTab("article" + id, '编辑文章[' + selecteds[0].title + ']', '${base}/admin/system/article/edit.jhtml?parentMenuNo=${(parentMenuNo)!""}&id=' + id);
		}
    }
    
	//发布
	function doPublish(){
		var selecteds = grid.getSelecteds();
      	if (selecteds.length == 0) {
      		LG.tip('请选择行!');
      		return;
      	}
		jQuery.ligerDialog.confirm('确定发布吗?', function(confirm){
			if (confirm) {
				LG.ajax({
					url: base + '/admin/system/article/doPublish.jhtml',
					data:{ids:LG.getIds(selecteds)},
					success: function(data){
						if(data.type == 'SUCCESS'){
							LG.showSuccess('发布成功！');
							f_reload();
						}else{
							LG.showError('发布失败！');
						}
					}
				});
			}
		});
	}
	
	function f_delete() {
      var selecteds = grid.getSelecteds();
      if (selecteds.length > 0) {
      	jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
      		if (confirm){
      			LG.ajax({
      				url: base + '/admin/system/article/delete.jhtml',
      				loading: '正在删除中...',
		            data: { ids: LG.getIds(selecteds) },
		            success: function () {
		            	LG.showSuccess('删除成功');
		                f_reload();
		            },
		            error: function (message) {
		                LG.showError(message);
		            }
		      	});
		  	}
		});
      } else {
          LG.tip('请选择行!');
      }
  };
  
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="functions">
		<div class="clearfix">
			<div style="float:left;">
				<span id="searchDefault">
					标题:<input type="text" class="formText" name="search_LIKE_title"/>&nbsp;
				</span>
				<span>
					首页置顶:[@u.select headerKey="" headerValue="全部" 
					headerButtom="false" list={"true":"是","false":"否"}
					name="search_EQ_isTop"/]
				</span>
				[#--
				<span>
					推荐:[@u.select headerKey="" headerValue="全部" 
					headerButtom="false" list={"true":"是","false":"否"}
					name="search_EQ_isRecommend"/]
				</span>
				--]
				<span>
					是否发布:[@u.select headerKey="" headerValue="全部" 
					headerButtom="false" list={"true":"是","false":"否"}
					name="search_EQ_isPublication"/]
				</span>
				<span>
					发布时间：
					<input type="text" name="search_GE_releaseDate" class="WdatePicker {dateFmt:'yyyy-MM-dd'}" style="width:100px"/>
					-
					<input type="text" name="search_LE_releaseDate" class="WdatePicker {dateFmt:'yyyy-MM-dd'}" style="width:100px"/>
				</span>
				<input type="button" id="search" class="button" value="搜索"/>
				<a href="#" id="search_btn_reset" face="Wingdings 3">解除搜索,显示全部数据</a>
			</div>
		</div>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>